﻿namespace LxCore
{
    public class LxSim : JsObject
    {
        public LxSim()
        {           
        }
        #region static
        public static LxSim Sim { get; private set; } = new LxSim();

        #endregion
        public FileManage FileManage { get; } = new();
        public LxInfo Info { get; } = new();
        public DefinitionsCenter Definitions { get; } = new();
        public StateAndScheduler Scheduler { get; } = new();
        public PhysicsCenter Physics { get; } = new();
        public FvMesh Mesh { get; } = new();
        public ConditionCenter Conditions { get; } = new();
        public FieldCenter Fields { get; } = new();
        public StepCenter Steps { get; } = new();
        public SolveCenter Solvers { get; } = new();
        public MonitorCenter Monitors { get; } = new();
        public ExcuteCenter Commands { get; } = new();
        public VisualCenter Visuals { get; } = new();
        public ToolBox Tools { get; } = new();
        public CalcManage CalcManage { get; } = new();

        public override void FromJsonKV(string key, IJsonReader jsReader)
        {
            switch (key)
            {
                case nameof(Info): jsReader.ReadObject(Info); break;
                case nameof(Definitions): jsReader.ReadObject(Definitions); break;
                case nameof(Physics): jsReader.ReadObject(Physics); break;
                case nameof(Mesh): jsReader.ReadObject(Mesh); break;
                case nameof(Conditions): jsReader.ReadObject(Conditions); break;
                case nameof(Fields): jsReader.ReadObject(Fields); break;
                case nameof(Steps): jsReader.ReadObject(Steps); break;
                case nameof(Solvers): jsReader.ReadObject(Solvers); break;
                case nameof(Monitors): jsReader.ReadObject(Monitors); break;
                case nameof(Visuals): jsReader.ReadObject(Visuals); break;
                default: base.FromJsonKV(key, jsReader); break;
            }
        }
        public override void ToJsonKV(IJsonWriter writer)
        {
            writer.WriteObject(nameof(Info), Info);
            writer.WriteObject(nameof(Definitions), Definitions);
            writer.WriteObject(nameof(Physics), Physics);
            writer.WriteObject(nameof(Mesh), Mesh);
            writer.WriteObject(nameof(Conditions), Conditions);
            writer.WriteObject(nameof(Fields), Fields);
            writer.WriteObject(nameof(Steps), Steps);
            writer.WriteObject(nameof(Solvers), Solvers);
            writer.WriteObject(nameof(Monitors), Monitors);
            writer.WriteObject(nameof(Visuals), Visuals);
            base.ToJsonKV(writer);
        }
    }
}